In this script, there is conducted the estimation for the measure_marginal approach for a single given env. The programs is the set of bytecode programs with varying number of opcodes. The measurements are time measurements of program runs or benchmarks. The estimation of each opcode is calculated as the regression against the number of a given opcode in the executed programs.

Parametrization. The evm client name env=nethermind, the file with programs programs=pg_marginal_full.csv, the file with measurements results=results_marginal_full_nethermind.csv,
the output csv file with estimated cost output_estimated_cost=reports-12.01.2025/estimated_cost_marginal_full_nethermind.csv, should the details be included in the report details=FALSE.

The comparision of result. Before and after removing outlying measurement. Switch removed_outliers to FALSE to see the comparison.

if (removed_outliers) {
  measurements = remove_compare_outliers(measurements, 'measure_total_time_ns', c(env))
}

Now we can investigate the linear regressions.

for (opcode in all_opcodes) {
  estimate = compute_all(opcode=opcode, env=env, use_median=TRUE, plots=ifelse(details,'all','scatter'))
  estimates[nrow(estimates) + 1, ] = c(opcode, estimate, env)
}

The resulting estimates based on the regressions above.

estimates
##                 op estimate_marginal_ns estimate_marginal_ns_stderr        env
## 1              ADD            63.715231                    4.789871 nethermind
## 2              MUL           109.610483                    3.563871 nethermind
## 3              SUB            51.673747                    6.658241 nethermind
## 4              DIV            54.692465                    2.071710 nethermind
## 5             SDIV            91.027349                    4.862008 nethermind
## 6              MOD            60.737285                    6.617234 nethermind
## 7             SMOD            96.499909                    2.751869 nethermind
## 8           ADDMOD           110.954260                    4.566538 nethermind
## 9           MULMOD           314.759717                    3.982696 nethermind
## 10             EXP           462.890371                    7.868380 nethermind
## 11      SIGNEXTEND            50.630391                    4.250879 nethermind
## 12              LT            39.407343                    3.856377 nethermind
## 13              GT            36.817957                    5.295451 nethermind
## 14             SLT            54.632824                    2.373638 nethermind
## 15             SGT            63.868799                    5.166645 nethermind
## 16              EQ            46.590982                    3.700799 nethermind
## 17          ISZERO            23.296090                    2.063296 nethermind
## 18             AND            19.272530                    4.581505 nethermind
## 19              OR            18.050428                    3.157556 nethermind
## 20             XOR            13.674686                    4.799435 nethermind
## 21             NOT            14.769845                    4.717023 nethermind
## 22            BYTE            42.176436                    3.299240 nethermind
## 23             SHL            76.966292                    3.050882 nethermind
## 24             SHR            80.239445                    5.948293 nethermind
## 25             SAR            89.436859                    3.783150 nethermind
## 26       KECCAK256           646.119986                    7.689621 nethermind
## 27         ADDRESS            22.961025                    2.598159 nethermind
## 28          ORIGIN            20.285499                    3.705124 nethermind
## 29          CALLER            23.533750                    2.211548 nethermind
## 30       CALLVALUE            15.188336                    3.940242 nethermind
## 31    CALLDATALOAD            55.560993                    3.962749 nethermind
## 32    CALLDATASIZE            24.591431                    2.150400 nethermind
## 33    CALLDATACOPY           144.801103                    5.455837 nethermind
## 34        CODESIZE            25.364873                    2.444191 nethermind
## 35        CODECOPY           143.378249                    4.439639 nethermind
## 36        GASPRICE            24.106405                    2.049310 nethermind
## 37     EXTCODESIZE           330.203327                    8.312141 nethermind
## 38     EXTCODECOPY           586.946148                   10.388927 nethermind
## 39  RETURNDATASIZE            34.506648                    2.342834 nethermind
## 40  RETURNDATACOPY           161.623265                    9.040767 nethermind
## 41     EXTCODEHASH           320.239647                    8.966475 nethermind
## 42        COINBASE            25.735394                    3.361952 nethermind
## 43       TIMESTAMP            31.197298                    3.883147 nethermind
## 44          NUMBER            30.256346                    2.600284 nethermind
## 45      DIFFICULTY            26.406383                    2.084243 nethermind
## 46        GASLIMIT            27.339424                    2.202820 nethermind
## 47         CHAINID            26.626050                    2.109687 nethermind
## 48     SELFBALANCE           104.421206                    2.717181 nethermind
## 49             POP             4.285116                    3.733317 nethermind
## 50           MLOAD            61.575113                    5.192128 nethermind
## 51         MSTORE8            76.640328                    2.133470 nethermind
## 52            JUMP            88.402968                   16.941679 nethermind
## 53           JUMPI           127.725710                   29.192880 nethermind
## 54              PC            20.136062                    3.638635 nethermind
## 55           MSIZE            27.107546                    3.625664 nethermind
## 56             GAS            30.166072                    3.093869 nethermind
## 57        JUMPDEST            18.031345                    3.263239 nethermind
## 58           PUSH0            32.104451                    2.928439 nethermind
## 59            LOG0           166.261554                    4.715946 nethermind
## 60            LOG1           190.639787                    7.646700 nethermind
## 61            LOG2           208.653779                    6.631589 nethermind
## 62            LOG3           235.516546                    5.915595 nethermind
## 63            LOG4           263.719347                    7.065969 nethermind
## 64            CALL          2382.239558                   41.242458 nethermind
## 65          RETURN           142.162390                   23.842888 nethermind
## 66    DELEGATECALL          2284.971105                   51.729387 nethermind
## 67      STATICCALL          2299.812249                   51.244667 nethermind
## 68          REVERT           415.461314                   81.845785 nethermind
## 69           PUSH1            23.882096                    2.533415 nethermind
## 70           PUSH2            17.653596                    4.272760 nethermind
## 71           PUSH3            20.635061                    2.265071 nethermind
## 72           PUSH4            23.593587                    2.038801 nethermind
## 73           PUSH5            19.572821                    2.346028 nethermind
## 74           PUSH6            22.237110                    2.815135 nethermind
## 75           PUSH7            22.610471                    2.515993 nethermind
## 76           PUSH8            16.748252                    2.656459 nethermind
## 77           PUSH9            19.176401                    3.043003 nethermind
## 78          PUSH10            22.038620                    3.447270 nethermind
## 79          PUSH11            22.312713                    2.772650 nethermind
## 80          PUSH12            25.091262                    2.929335 nethermind
## 81          PUSH13            22.798301                    1.947995 nethermind
## 82          PUSH14            24.558879                    2.708282 nethermind
## 83          PUSH15            21.083966                    2.339003 nethermind
## 84          PUSH16            22.755745                    2.749059 nethermind
## 85          PUSH17            23.506305                    1.154316 nethermind
## 86          PUSH18            25.218325                    4.111232 nethermind
## 87          PUSH19            21.339622                    1.559011 nethermind
## 88          PUSH20            23.063460                    3.328507 nethermind
## 89          PUSH21            20.815947                    1.893693 nethermind
## 90          PUSH22            25.570660                    2.240526 nethermind
## 91          PUSH23            20.106934                    2.909589 nethermind
## 92          PUSH24            19.399639                    1.630340 nethermind
## 93          PUSH25            19.934286                    3.232071 nethermind
## 94          PUSH26            23.887270                    2.758787 nethermind
## 95          PUSH27            23.145329                    1.858392 nethermind
## 96          PUSH28            23.150061                    1.650681 nethermind
## 97          PUSH29            24.927244                    3.442688 nethermind
## 98          PUSH30            19.689748                    2.128168 nethermind
## 99          PUSH31            22.316060                    1.888328 nethermind
## 100         PUSH32            14.874329                    3.253756 nethermind
## 101           DUP1            17.860008                    2.339153 nethermind
## 102           DUP2            16.792699                    2.410961 nethermind
## 103           DUP3            12.685711                    3.207659 nethermind
## 104           DUP4            19.120011                    4.458534 nethermind
## 105           DUP5            23.359480                    4.687635 nethermind
## 106           DUP6            15.900989                    3.132831 nethermind
## 107           DUP7            19.755760                    4.288225 nethermind
## 108           DUP8            16.177556                    3.598258 nethermind
## 109           DUP9            19.206907                    2.873941 nethermind
## 110          DUP10            17.367750                    3.944860 nethermind
## 111          DUP11             6.825443                    1.664508 nethermind
## 112          DUP12            11.815561                    3.011531 nethermind
## 113          DUP13            15.527896                    2.286547 nethermind
## 114          DUP14            15.367196                    2.736498 nethermind
## 115          DUP15            17.575683                    3.233597 nethermind
## 116          DUP16            10.711575                    2.406507 nethermind
## 117          SWAP1            18.025784                    3.628061 nethermind
## 118          SWAP2            18.706290                    2.583231 nethermind
## 119          SWAP3            11.922176                    3.036852 nethermind
## 120          SWAP4            18.515913                    3.120026 nethermind
## 121          SWAP5            15.233179                    4.725594 nethermind
## 122          SWAP6            13.259749                    2.201317 nethermind
## 123          SWAP7            11.999567                    3.736074 nethermind
## 124          SWAP8            14.498572                    2.873143 nethermind
## 125          SWAP9            17.229198                    4.960720 nethermind
## 126         SWAP10            13.101425                    3.259242 nethermind
## 127         SWAP11            14.472840                    4.680416 nethermind
## 128         SWAP12            14.763929                    2.530252 nethermind
## 129         SWAP13            11.455994                    4.030405 nethermind
## 130         SWAP14            17.951477                    2.995847 nethermind
## 131         SWAP15            16.827982                    3.090227 nethermind
## 132         SWAP16            17.414574                    2.228020 nethermind

The results are exported to reports-12.01.2025/estimated_cost_marginal_full_nethermind.csv.